<cfmodule template="../../tag/layout.cfm">
<cfinclude template="../../inc/lib.cfm">
<!--- 表格显示 --->
<table id="grid"></table>
<div id="toolbar" style="display: none;">
	<table>
		<tr>
			<td><a onclick="redoFun();" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'ext-icon-resultset_next'">展开</a><a onclick="undoFun();" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'ext-icon-resultset_previous'">折叠</a></td>
			<td><a onclick="grid.treegrid('reload');" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'ext-icon-arrow_refresh'">刷新</a></td>
		</tr>
	</table>
</div>

</cfmodule>
<cfscript>
	if( structKeyExists(rc, "categorytypeid")  && rc.categorytypeid > 0 ){
		categorytypeid = rc.categorytypeid;
	}else{
		categorytypeid = 0;
	}
</cfscript>
<script type="application/javascript">
var closeDialog = function($dialog) {
	$dialog.dialog('destroy');
}

var redoFun = function() {
	var node = grid.treegrid('getSelected');
	if (node) {
		grid.treegrid('expandAll', node.id);
	} else {
		grid.treegrid('expandAll');
	}
};
var undoFun = function() {
	var node = grid.treegrid('getSelected');
	if (node) {
		grid.treegrid('collapseAll', node.id);
	} else {
		grid.treegrid('collapseAll');
	}
};

$(function(){
	//列表操作
	var gird;
	grid = $('#grid').treegrid({
		fit:true,
	    border:false,
        rownumbers: true,
        animate:true,
        collapsible:false,
        fitColumns:true,
        pagination: false,
        url:'?action=ads.category&categorytypeid=<cfoutput>#categorytypeid#</cfoutput>',
        idField:'id',
        treeField:'text',
        columns:[[
            {title:'id',field:'id',width:'50',hidden: false},
            {field:'text',title:'类别名称',width:'200'},
	        {field:'description',title:'类别描述',width:'180'},
	        {field:'rcount',title:'广告统计',width:'80',align:'center'},
	        {
				title : '操作',
				field : 'action',
				width : '60',
				formatter : function(value, row) {
					var str = '';
					str += fw.formatString('<a href="?action=ads.lists&categoryid={0}&categorytypeid={1}"><img class="iconImg ext-icon-note_go" title="进入"/></a>', row.id,<cfoutput>#categorytypeid#</cfoutput>);
					return str;
				}
			}
        ]],
        toolbar: '#toolbar',
		onLoadSuccess : function(data) {
			$('.iconImg').attr('src', fw.pixel_0);
		}
    });

});
</script>